<% /* $Id: contestproblems.jsp 132 2011-08-26 10:23:42Z altdotua@gmail.com $ */ %>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ include file="../header.jsp" %>

<h2 align="center">Contest Problems</h2>

<%= (new ContestProblemsFormatter()).format(ContestProblemsModel.getEntries(filter)) %>

<%
	ContestProblemEntry entry = ContestProblemsModel.getEntry(Long.parseLong(request.getParameter("id")));
%>
<h2><%= entry == null ? "Add contest problem" : "Edit contest problem\"" + entry + "\"" %></h2>

<form action="<%= Linker.link("contestproblems") %>" method="post">
	<input type="hidden" name="action" value="edit">
	<input type="hidden" name="return" value="<%= request.getRequestURL() %>">
  <p><input type="hidden" name="id" value="<%= null == entry ? "" : entry.getId() %>"></p>
  <p>SID: <input name="sid" value="<%= null == entry ? "" : entry.getSid() %>"></p>
  <p>Name: <input name="name" value="<%= null == entry ? "" : entry.getName() %>"></p>  
  <p>Contest<select name="contestId">
			<%
				List<ContestEntry> contests = ContestsModel.getAllEntries();
				String contestId = null != entry ? entry.getContestId().toString() : "";
				for (ContestEntry contest2 : contests) {
			%>
				<option value="<%=contest2.getId()%>" <%= contest2.getId().toString().equals(contestId) ? " selected=\"selected\"" : "" %>><%=contest2%> 
			<%
 	}
 			%>
	</select></p>  
  <p>Problem<select name="problemId">
			<%
				List<ProblemEntry> problems = ProblemsModel.getAllEntries();
				String problemId = null != entry ? entry.getProblemId().toString() : "";
				for (ProblemEntry problem : problems) {
			%>
				<option value="<%=problem.getId()%>" <%= problem.getId().toString().equals(problemId) ? " selected=\"selected\"" : "" %>><%=problem%> 
			<%
 	}
 			%>
	</select></p>  
  <p><input type="checkbox" name="active" <%= null == entry || entry.getActive() ? "checked='checked'" : "" %>>Active?</p>
  <p><input type="submit" value="Submit"></p>
</form>


<%@ include file="../footer.jsp" %>
